<script setup>
import { ref, onMounted } from 'vue'
import * as echarts from 'echarts'
function initChart() {
  const option = {
    tooltip: {
      trigger: 'item'
    },
    legend: {
      top: '0%',
      left: 'center',
      textStyle: {
        color: 'white'
      }
    },
    series: [
      {
        type: 'pie',
        radius: ['30%', '55%'],
        avoidLabelOverlap: false,
        padAngle: 5,
        itemStyle: {
          borderRadius: 5
        },
        label: {
          position: 'outer',
          alignTo: 'none',
          bleedMargin: 5,
          color: 'white'
        },
        emphasis: {
          label: {
            show: true,
            fontSize: 20
          }
        },
        labelLine: {
          show: true,
          length: 10,
          length2: 15
        },
        data: [
          { value: 1048, name: '水费' },
          { value: 735, name: '电费' }
        ]
      }
    ]
  }
  echarts.init(document.getElementById('content-left')).setOption(option)
}
onMounted(() => {
  initChart()
})
</script>

<template>
  <div class="wrapper">
    <div class="top">
      <div class="top-title">总体费用</div>
      <div class="top-content">
        <div class="content-left" id="content-left"></div>
        <div class="content-right">
          <div class="item">
            <div class="item-top-left">
              <span class="iconfont icon-shuidibeifen" style="color: #036879"></span>
            </div>
            <div class="item-top-right">
              <span>5000</span>
              <span>水费(元)</span>
            </div>
          </div>
          <div class="item">
            <div class="item-top-left">
              <span class="iconfont icon-shandian" style="color: #d71d05"></span>
            </div>
            <div class="item-top-right">
              <span>5000</span>
              <span>水费(元)</span>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div class="bottom">
      <div class="bottom-title">设备在线</div>
      <div class="bottom-content">
        <div class="row">
          <div class="grid-item">
            <span>楼宇数量:</span>
            <div>10栋</div>
          </div>
          <div class="grid-item">
            <span>房间数量:</span>
            <div>3000间</div>
          </div>
        </div>
        <div class="row">
          <div class="grid-item">
            <span>设备数量:</span>
            <div>6000个</div>
          </div>
          <div class="grid-item">
            <span>设备类型:</span>
            <div>2种</div>
          </div>
          <div class="grid-item">
            <span>直饮水设备:</span>
            <div>3000个</div>
          </div>
        </div>
        <div class="row">
          <div class="grid-item">
            <span>水电表设备:</span>
            <div>3000个</div>
          </div>
          <div class="grid-item">
            <span>在线数量:</span>
            <div>6000个</div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<style lang="scss" scoped>
.wrapper {
  width: 400px;
  height: 100%;
 @include display-flex-center;
  flex-direction: column;
  .top {
    width: 100%;
    height: 250px;
    margin-bottom: 24px;
    overflow: hidden;
    background-color: $bigScreenBg;
    padding: 0 20px;
    .top-content {
      height: calc(100% - 40px);
      display: flex;
      justify-content: space-between;
      .content-left {
        flex: 1;
      }
      .content-right {
        width: 100px;
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: space-between;
        flex-direction: column;
        .item {
          width: 100%;
          height: 90px;
          display: flex;
          .item-top-left {
            @include display-flex-center;
            @include colorWhite;
            width: 55px;
            height: 100%;
            span {
              font-size: 45px;
            }
          }
          .item-top-right {
            flex: 1;
            @include display-flex-center;
            flex-direction: column;
            @include colorWhite;
            span {
              text-align: left;
              display: inline-block;
              width: 100%;
              margin: 4px 0;
            }
          }
        }
      }
    }
  }
  .bottom {
    width: 100%;
    height: 250px;
    background-color: $bigScreenBg;
    padding: 0 20px;
    .bottom-content {
      width: 100%;
      height: calc(100% - 40px);

    .row{
        width: 100%;
        @include colorWhite;
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 35px;
    }
    }
  }
}
.top-title,
.bottom-title {
  @include colorWhite;
  text-align: left;
  height: 40px;
  border-bottom: 1px solid #ccc;
  line-height: 40px;
  font-weight: bold;
}
</style>
